package com.itheima.cloud.order.controller;

import com.itheima.cloud.order.service.OrderService;
import com.itheima.cloud.pojo.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description:
 * @Version: V1.0
 */
@RestController
@RequestMapping("order")
public class OrderController {

    @Autowired
    OrderService orderService;

    @Value("${server.port}")
    private String port;


    /**
     * 根据用户名查询订单列表
     * @param username   /order/findOrderByUserId/{itcast}
     * @return List<Order>
     */
    @GetMapping("findOrderByUserId/{username}")
    public List<Order> findOrder(@PathVariable("username") String username) {

        System.out.println("OrderController findOrder PORT=" + port);

        return orderService.findOrderByUserId(username);
    }

}
